package org.oa.ai.config;

import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class UserChatMemoryStore implements ChatMemoryStore {

    private Map<Object, List<ChatMessage>> chatMap = new HashMap<>();

    @Override
    public List<ChatMessage> getMessages(Object o) {
        return chatMap.get(o);
    }

    @Override
    public void updateMessages(Object o, List<ChatMessage> list) {
        chatMap.put(o, list);
    }

    @Override
    public void deleteMessages(Object o) {
        chatMap.remove(o);
    }
}
